package com.ag.hmk.service.impl;

import java.util.List;

import com.ag.bean.TbExpert;
import com.ag.common.IDUtil;
import com.ag.hmk.dao.HmkExpertDAO;
import com.ag.hmk.service.ExpertService;

/**
 * 
 * @author 黄木看
 *专家库服务层接口实现
 */
public class ExpertServImpl implements ExpertService {

	private HmkExpertDAO hmkExpertDAO;
	
	/*
	 *删除专家记录（by id） 
	 */
	public void delExpert(TbExpert expert) {
		if (expert!=null) {
			expert.setA(IDUtil.DELETE);
			hmkExpertDAO.attachDirty(expert);
		}
	}
	
	/*
	 *查询所有专家库记录 
	 */
	public List<TbExpert> findAllExpert() {
		return hmkExpertDAO.findAll();
	}

	/*
	 * 查询一条专家记录（by id）
	 */
	public TbExpert findByExpertID(String expertID) {
		if (expertID!=null) {
			return hmkExpertDAO.findById(expertID);
		} else {
			return null;
		}
	}

	/*
	 * 保存或更新专家记录
	 */
	public void saveExpert(TbExpert expert) {
		if (expert!=null) {
			expert.setA(IDUtil.PRESERVE);
			hmkExpertDAO.attachDirty(expert);
		}
		
	}

	public void setHmkExpertDAO(HmkExpertDAO hmkExpertDAO) {
		this.hmkExpertDAO = hmkExpertDAO;
	}

}
